<template>
  <div>
    <el-card class="box-card center-card" style="margin-top:20px">
      <div class="text item">

        <el-form ref="queryForm" :model="queryParams" :rules="rules" label-width="0"
                 style="width: 230px;margin: 30px auto;">
          <el-form-item label="" prop="type">
            <el-select v-model="queryParams.type"
                       placeholder="请选择考试类别"
                       @change="changeSelect"
                       clearable>
              <el-option
                v-for="item in examList"
                :key="item.value"
                :label="item.text"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button @click="resetForm">重置</el-button>
            <el-button type="primary" @click="submitForm">确定</el-button>
          </el-form-item>
        </el-form>

      </div>
    </el-card>
  </div>
</template>

<script>
  import {} from "@/api/toolsystem/grade";
  import Cookies from "js-cookie";

  export default {
    name: "selectExamType",
    props:{
      selectType: [Number,String]
    },
    data() {
      return {
        // 查询参数
        queryParams: {
          type: this.selectType, // 学科id
        },
        rules: {
          type: [
            {
              required: true,
              message: "请选择科目",
              trigger: "blur"
            }
          ],
        },
        // 考试类别列表
        examList: [
          {
            value: 1,
            text: '校考'
          }, {
            value: 2,
            text: 'TDA/TACA/TGA'
          }
          // , {
          //   value: 3,
          //   text: 'TACA'
          // }, {
          //   value: 4,
          //   text: 'TGA'
          // },
        ]
      }
    },
    watch:{
      selectType(val){
        this.queryParams.type = Number(val);
      }
    },
    created() {
    },
    methods: {
      changeSelect(val){
        this.$emit('changeType', val)
      },
      submitForm() {
        this.$refs['queryForm'].validate((valid) => {
          if (!valid) return
            Cookies.set("tool_system_grade_selectExam", this.queryParams.type);
          })
      },
      // 重置按钮重置
      resetForm() {
        this.$refs['queryForm'].resetFields();
      }
    }
  }
</script>

<style scoped lang="scss">

</style>

